<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
<body>
    <ui:composition template="/WEB-INF/template.xhtml">
        <ui:define name="topnav">
            <ui:include src="/WEB-INF/incl/store_nav.xhtml">
                <ui:param name="page" value="orders" />
            </ui:include>
        </ui:define>

        <ui:define name="sidebar">
            <ui:include src="/WEB-INF/incl/login.xhtml" />
            <ui:include src="/WEB-INF/incl/cart.xhtml" />
        </ui:define>
        
        <ui:define name="body">
            <h1>Your orders:</h1>

            <f:subview id="no_orders" rendered="#{!orders.rowAvailable}">
                <p>You have not placed any orders.</p>
            </f:subview>

            <f:subview id="ordersummary" rendered="#{orders.rowAvailable}">
                
            <h:dataTable value="#{orders}" var="item"
                         styleClass="dvdtable" 
                         headerClass="dvdtablehead"
                         rowClasses="dvdtableodd,dvdtableeven"
                         columnClasses="dvdtablecol">
                <h:column>
                    <f:facet name="header">Order Id</f:facet>
                    #{item.orderId}
                </h:column>                        
                <h:column>
                    <f:facet name="header">Date</f:facet>
                    <h:outputText value="#{item.orderDate}">
                        <s:convertDateTime type="both" dateStyle="full"/> 
                    </h:outputText>
                </h:column>                        
                <h:column>
                    <f:facet name="header">Status</f:facet>
                    #{item.status}
                </h:column>                        

                <h:column>
                    <s:button action="#{showorders.detailOrder}" value="Show Details" />
                </h:column>
                <h:column>
                    <s:button action="#{showorders.cancelOrder}" value="Cancel" rendered="#{item.open}"/>
                </h:column>
            </h:dataTable>

            <f:subview id="orderdetails" rendered="#{myorder != null}">
                <div class="cntInfo">
                    <h2>Order Details</h2>

                    <h:panelGrid columns="2">
                        <h:outputText value="Order Id:" />
                        <h:outputText value="#{myorder.orderId}" />
                        
                        <h:outputText value="Status:" />
                        <h:panelGroup>
                            <h:outputText value="#{myorder.status}" />
                            <h:outputText value="(Tracking Number: #{myorder.trackingNumber})" 
                                          rendered="#{myorder.statusCode==3}"/>
                        </h:panelGroup>
                        
                        <h:outputText value="Order date:" />
                        <h:outputText value="#{myorder.orderDate}">
                            <s:convertDateTime type="both" dateStyle="full"/> 
                        </h:outputText>
                        
                        <h:outputText value="Delivery date:" />
                        <h:outputText value="#{myorder.deliveryDate}">
                            <s:convertDateTime type="both" dateStyle="full"/> 
                        </h:outputText>                        
                        
                        <h:outputText value="Net Amount:" />
                        <h:outputText value="#{myorder.netAmount}">
                            <f:convertNumber type="currency" currencySymbol="$" />
                        </h:outputText>
                        
                        <h:outputText value="Tax:" />
                        <h:outputText value="#{myorder.tax}">
                            <f:convertNumber type="currency" currencySymbol="$" />
                        </h:outputText>
                        
                        <h:outputText value="Total Amount:" />
                        <h:outputText value="#{myorder.totalAmount}">
                            <f:convertNumber type="currency" currencySymbol="$" />
                        </h:outputText>
                    </h:panelGrid>
                    

                    <div class="cntInfo">
                        <h:dataTable value="#{myorder.orderLines}" var="item"
                                     styleClass="dvdtable" 
                                     headerClass="dvdtablehead"
                                     rowClasses="dvdtableodd,dvdtableeven"
                                     columnClasses="dvdtablecol">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="#{messages.cartTitleColumn}" />
                                </f:facet>
                                <h:outputText value="#{item.product.title}" />
                            </h:column>                        
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="#{messages.cartActorColumn}" />
                                </f:facet>
                                <h:outputText value="#{item.product.actors[0].name}" />
                            </h:column>                        
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="#{messages.cartQuantityColumn}" />
                                </f:facet>
                                <h:outputText value="#{item.quantity}" />
                            </h:column>                                        
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="#{messages.cartPriceColumn}" />
                                </f:facet>
                                <h:outputText value="#{item.product.price}">
                                    <f:convertNumber type="currency" currencySymbol="$" />
                                </h:outputText>
                            </h:column>                        
                        </h:dataTable>
                    </div>
                </div>
            </f:subview>
        </f:subview>
        </ui:define>
    </ui:composition>
</body>
</html>




